package com.xzzz.irda.tracker.server;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@MapperScan(basePackages = {"com.xzzz.irda.tracker.server.mappers"})
public class TrackerServerConfiguration {

    @Bean(name = "trackerRepository")
    @ConditionalOnProperty(value = "xzzz.tracker.repository.type", havingValue = "elasticsearch")
    public TrackerMetricServiceByElasticSearch traceMetricServiceByEs() {
        return new TrackerMetricServiceByElasticSearch();
    }

    @Bean(name = "trackerRepository")
    @ConditionalOnProperty(value = "xzzz.tracker.repository.type", havingValue = "mysql")
    public TrackerMetricServiceByMySql trackerMetricServiceByMysql() {
        return new TrackerMetricServiceByMySql();
    }

    @Bean
    public TrackerMetricController traceMetricController() {
        return new TrackerMetricController();
    }

}
